"""
Does broadcasting by issuing a parallel send.

This method makes it impossible to propagate a poison backwards, since it will block in the Parallel call.

A possible fix, might be to create a Any2OneChannel from broadcastFunc to all proccesses in the Parallel construct. This would propagate a poison. 

Copyright (c) 2008 Rune M. Friborg, runef@diku.dk.
See LICENSE.txt for licensing details (GPLv2).
"""

from common import *
import random
import copy
import time


def broadcastFunc(cin, *cout_args):
    while 1:
        t = cin()

        def f(cout):
            return Process(cout, copy.deepcopy(t))

        apply(Parallel, map(f, cout_args))
